/*
 * Copyright (c) 2025 EasyAdmin
 * All rights reserved.
 *
 * This file is part of the [EasAdmin] project.
 * Unauthorized copying of this file, via any medium, is strictly prohibited.
 * Proprietary and confidential.
 *
 * Author: EasyAdmin ( 1073602@qq.com )
 * Website: https://www.xhxiao.com
 */
package com.easy.module.system.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.easy.framework.common.validate.Add;
import com.easy.framework.common.validate.Update;
import com.easy.framework.database.entity.LogicDeleteEntity;
import com.easy.framework.poi.annotation.Excel;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.Getter;
import lombok.Setter;

import java.util.ArrayList;
import java.util.List;

/**
 * 部门表 实体
 *
 * @author EasyAdmin ( 1073602@qq.com )
 * @date 2025-08-19
 */
@Getter
@Setter
@TableName("sys_dept")
public class SysDept extends LogicDeleteEntity
{
    private static final long serialVersionUID = 1L;

    /**
     * 部门编号
     *
     */
    @Excel(name = "部门编号")
    @TableId(type = IdType.AUTO)
    private Long id;


    /**
     * 父级编号
     *
     */
    @Excel(name = "父级编号")
    private Long parentId;


    /**
     * 所属机构
     *
     */
    @Excel(name = "所属机构")
    private Long orgId;


    /**
     * 祖级
     *
     */
    @Excel(name = "祖级")
    @Size(message = "祖级长度必须小于255个字符", max = 255, groups = {Add.class, Update.class})
    private String ancestors;


    /**
     * 类型（1机构，2部门）
     *
     */
    @Excel(name = "类型（1机构，2部门）")
    private Integer deptType;


    /**
     * 部门名称
     *
     */
    @Excel(name = "部门名称")
    @NotBlank(message = "部门名称不能为空", groups = {Add.class, Update.class})
    @Size(message = "部门名称长度必须小于30个字符", max = 30, groups = {Add.class, Update.class})
    private String deptName;


    /**
     * 顺序
     *
     */
    @Excel(name = "顺序")
    @NotNull(message = "顺序不能为空", groups = {Add.class, Update.class})
    private Integer sort;


    /**
     * 负责人
     *
     */
    @Excel(name = "负责人")
    @Size(message = "负责人长度必须小于20个字符", max = 20, groups = {Add.class, Update.class})
    private String leader;


    /**
     * 联系电话
     *
     */
    @Excel(name = "联系电话")
    @Size(message = "联系电话长度必须小于11个字符", max = 11, groups = {Add.class, Update.class})
    private String phone;


    /**
     * 邮箱
     *
     */
    @Excel(name = "邮箱")
    @Size(message = "邮箱长度必须小于50个字符", max = 50, groups = {Add.class, Update.class})
    private String email;


    /**
     * 状态（0正常 1停用）
     *
     */
    @Excel(name = "状态（0正常 1停用）")
    @NotNull(message="状态不能为空", groups = {Add.class,Update.class})
    private Integer status;


    /**
     * 备注
     *
     */
    @Excel(name = "备注")
    @Size(message = "备注长度必须小于255个字符", max = 255, groups = {Add.class, Update.class})
    private String remark;


    @TableField(exist = false)
    private String parentName;

    @TableField(exist = false)
    private List<SysDept> children = new ArrayList<>();

    @TableField(exist = false)
    private boolean hasChildren = false;

}
